package com.weitu.securitycheck.service.impl;

import com.weitu.securitycheck.entity.CheckRecord;
import com.weitu.securitycheck.entity.CheckRecordCriteria;
import com.weitu.securitycheck.mapper.CheckRecordMapper;
import com.weitu.securitycheck.service.CheckRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CheckRecordServiceImpl implements CheckRecordService {
    private final CheckRecordMapper checkRecordMapper;

    private static final Logger logger = LoggerFactory.getLogger(CheckRecordServiceImpl.class);

    @Autowired
    public CheckRecordServiceImpl(CheckRecordMapper checkRecordMapper) {
        this.checkRecordMapper = checkRecordMapper;
    }

    @Override
    public int countByCriteria(CheckRecordCriteria example) {
        int count = this.checkRecordMapper.countByCriteria(example);
        logger.debug("count: {}", count);
        return count;
    }

    @Override
    public CheckRecord selectByPrimaryKey(String id) {
        return this.checkRecordMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<CheckRecord> selectByCriteria(CheckRecordCriteria example) {
        return this.checkRecordMapper.selectByCriteria(example);
    }

    @Override
    @Transactional
    public int deleteByPrimaryKey(String id) {
        return this.checkRecordMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public int updateByPrimaryKeySelective(CheckRecord record) {
        return this.checkRecordMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    @Transactional
    public int updateByCriteriaSelective(CheckRecord record, CheckRecordCriteria example) {
        return this.checkRecordMapper.updateByCriteriaSelective(record, example);
    }

    @Override
    @Transactional
    public int insertSelective(CheckRecord record) {
        return this.checkRecordMapper.insertSelective(record);
    }

    @Override
    @Transactional
    public boolean insertBatch(List<CheckRecord> records) {
        return this.checkRecordMapper.insertBatch(records) == records.size();
    }
}